<template>
	<div class="container">
		<div class="jx-container">
      <div class="select-type">
        <div class="item">
          <span>状态：</span>
          <div class="right">
            <span v-for="(item, index) in statuslist" :key="index" :class="params_list.status == item ? 'active' : ''" @click="selected(item)">{{item}}</span>
          </div>
        </div>
      </div>
      <div class="jx-table">
        <el-table :data="list" border style="width: 100%" v-loading="boo.loading">
          <el-table-column type="index" label="序列" width="60" align="center">
            <template slot-scope="scope">
              <span>{{(scope.$index + 1) + ((params_list.page - 1) * params_list.size)}}</span>
            </template>
          </el-table-column>
          <el-table-column prop="institutionName" label="机构名称" align="center">
          </el-table-column>
          <el-table-column prop="institutionProvince" label="所在地区" align="center" :show-overflow-tooltip="true">
          </el-table-column>
          <el-table-column prop="institutionApplyAt" label="提交时间" width="150" align="center" :show-overflow-tooltip="true">
          </el-table-column>
          <el-table-column prop="institutionCatalog" label="机构类型" align="center" :show-overflow-tooltip="true">
          </el-table-column>
          <el-table-column prop="institutionApplyStatus" label="状态" align="center" >
          </el-table-column>
          <el-table-column label="操作" width="120" align="center">
            <template slot-scope="scope">
              <el-button v-if="scope.row.institutionApplyStatus == '已认证，待审核'" @click="checkRow(scope.row,1)" type="text" size="small">审核</el-button>
              <el-button v-else @click="checkRow(scope.row,2)" type="text" size="small">查看</el-button>
            </template>
          </el-table-column>
        </el-table>
        <div v-if="list.length != 0" class="jx-pagination">
          <el-pagination @current-change="pageChange" @size-change="handleSizeChange" :current-page="params_list.page" :page-sizes="[10,50,100]" :page-size="params_list.size" layout="total, sizes, prev, pager, next, jumper"
            :total="other.allRow">
          </el-pagination>
        </div>
      </div>
    </div>
	</div>
</template>

<script>
	export default {
		data() {
			return {
        https: {
          status: this.$api.common.dict,
          enter: this.$api.merchant.sfenter,
        },
        boo: {
          loading: false,
        },
        other: {
          allRow: 1,
        },
        list: '',
        statuslist: '', // 状态
        params_list: {
          page: 1,
          size: 10,
          status: '',
        },
			}
		},
		mounted(){
      let _self = this
      _self.getList()
      _self.getDict()
    },
		methods: {
      getDict(){
        let _self = this
        let params = {
          dictCode: 'institutionApplyStatus',
        }
        let success = (res)=>{
          res = res.data
          if(res.retCode == 1){
            _self.statuslist = res.retObject
          }else{
            _self.$message.error(res.retMsg)
          }
        }
        _self.$axios.get(_self.https.status, params, success) 
      },
      getList(){
        let _self = this
        let params = {
          institutionApplyStatus: _self.params_list.status || '',
          pageNumber: _self.params_list.page,
          pageSize: _self.params_list.size,
        }
        _self.boo.loading = true
        let success = (res)=>{
          res = res.data
          if(res.retCode == 1){
            _self.list = res.retObject.list
            _self.other.allRow = Number(res.retObject.totalRow)
          }else{
            _self.$message.error(res.retMsg)
          }
          _self.boo.loading = false
        }
        _self.$axios.get(_self.https.enter.list, params, success) 
      },
      pageChange(val){
        let _self = this
        _self.params_list.page = val
        _self.getList()
      },
      handleSizeChange(val) {
        let _self = this
        _self.params_list.size = val
        _self.getList()
      },
      selected(item){
        let _self = this
        _self.params_list.status = item
        _self.getList()
      },
      checkRow(item,type){
        let _self = this
        let params = {
          path: '/merchant/detail/sfenter_detail?id=',
          query: item.institutionApplyId + '&type=' + type
        }
        _self.$router.push(params.path + params.query)
      },
    }
	}

</script>
<style scoped lang="sass">
</style>
